import mysql.connector
from mysql.connector import Error

config = {
    'user': 'root',
    'password': 'jsti@2024',
    'host': '192.168.110.235',
    'port': '8306',
    'database': 'bid',
}

class MySQLDatabase:
    def __init__(self, config):
        self.config = config
        self.cnx = None
        self.cursor = None

    def connect(self):
        try:
            self.cnx = mysql.connector.connect(**self.config)
            self.cursor = self.cnx.cursor()
        except Error as e:
            print(f"Error connecting to MySQL Database: {e}")
    def close(self):
        if self.cursor:
            self.cursor.close()
        if self.cnx:
            self.cnx.close()
    def select_auto(self, query):
        try:
            self.cursor.execute(query)
            result = self.cursor.fetchall()
            return result
        except Error as e:
            print(f"Error selecting from table: {e}")
            return None

my_opr_mysql_database = MySQLDatabase(config)